public String reverseStr(String s, int k) {
    char[] arr = s.toCharArray();				
    for(int i = 0; i < arr.length; i += (2*k)){  
        if(i + k <= arr.length){
            reverse(arr,i,i+k-1);  				
            continue;
        }
        reverse(arr,i,arr.length-1);  			
    }
    return new String(arr);
}

public void reverse(char[] s,int i,int j){
    for(int m = i,n = j; m < n; m++,n--){
        char tmp = s[m];
        s[m] = s[n];
        s[n] = tmp;
    }
}
